import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

//1：定义类继承WritableComparator 类
public class MyGrouping extends WritableComparator {
    //2：调用父类的构造
    public MyGrouping(){
        super(CovidGroupingBean.class,true);
    }

   //3：重写compare方法，自定义分组规则
    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        CovidGroupingBean c1 = (CovidGroupingBean)a;
        CovidGroupingBean c2 = (CovidGroupingBean)b;

        return Integer.toString(c1.getPartid()).compareTo(Integer.toString(c2.getPartid())); // 1  0  -1
    }
}
